package com.stormrage.edu.dao.learn.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.learn.LeaBunchOperDao;
import com.stormrage.entity.learn.LeaBunchOper;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @Title: LeaBunchScoreDaoImpl.java
 * @Package com.stormrage.edu.dao.learn.impl
 * @Description: 班级实操成绩 Dao
 * @author www.stormragetech.com
 * @date 2016年4月27日
 * @version V1.0
 */
@Repository
public class LeaBunchOperDaoImpl extends MysBaseDao implements LeaBunchOperDao {

	private static final Logger logger = LoggerFactory.getLogger(LeaBunchOperDaoImpl.class);

	@Override
	public Integer create(final LeaBunchOper arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 Create 】- 开始运行 ");

		final String query = "INSERT INTO lea_bunch_oper (bunch_id, locked) VALUES (:bunchId, :locked)";
		logger.debug(" 数据库执行语句为 " + query);

		Integer index = create(query, arg0);

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 Create 】- 完成运行 ");
		return index;

	}

	@Override
	public void update(final LeaBunchOper arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 update 】- 开始运行 ");

		final String query = "UPDATE lea_bunch_oper SET bunch_id = :bunchId, excel = :excel, score_excel = :scoreExcel,"
				+ " locked = :locked WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		update(query, arg0);

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 update 】- 完成运行 ");

	}

	@Override
	public LeaBunchOper queryById(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 queryById 】- 开始运行 ");

		final String query = "SELECT * FROM lea_bunch_oper WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		LeaBunchOper entity = queryObject(query, LeaBunchOper.class, map);

		logger.debug(" 【 Dao 】-【 LeaBunchOperDao 】-【 queryById 】- 完成运行 ");
		return entity;

	}

}
